package com.hunttown.mes.rpc.domain.enums.task;

import java.util.HashMap;
import java.util.Map;

/**
 * 重复周期：1永不 2每天 3每周 4每两周 5每月 6每年 7每个工作日
 * created by wangjunfu on 2018/11/6
 */
public enum CycleTypeEnum {
    NONE(1, "一次性"),
    DAY(2, "每天"),
    WEEK(3, "每周"),
    TWOWEEK(4, "每两周"),
    MONTH(5, "每月"),
    YEAR(6, "每年"),
    WORKDAY(7, "每个工作日");

    private final int key;
    private final String value;

    CycleTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (CycleTypeEnum temp : CycleTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (CycleTypeEnum temp : CycleTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
